{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "a121952c",
   "metadata": {},
   "source": [
    "## 列表是一个有序的对象集合"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2a15b175",
   "metadata": {},
   "source": [
    "### 1.按字面创建列表"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "66f7f1c0",
   "metadata": {},
   "source": [
    "### 将[]赋给一个名为prices的变量，来创建一个空列表"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "803d4881",
   "metadata": {},
   "outputs": [],
   "source": [
    "prices = []\n",
    "temps =[32.0,212.0,0.0,81.6,100.0,45.3]\n",
    "words = ['hello','world']\n",
    "car_details = ['Toyota','Rav4',2.2,60,60807]\n",
    "everything = [prices,temps,words,car_details]\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3ec1373d",
   "metadata": {},
   "source": [
    "### 开始和结束列表"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "11bff637",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['T',\n",
       " 'h',\n",
       " 'e',\n",
       " ' ',\n",
       " 'H',\n",
       " 'i',\n",
       " 't',\n",
       " 'c',\n",
       " 'h',\n",
       " 'h',\n",
       " 'i',\n",
       " 'k',\n",
       " 'e',\n",
       " 'r',\n",
       " \"'\",\n",
       " 's',\n",
       " ' ',\n",
       " 'G',\n",
       " 'u',\n",
       " 'i',\n",
       " 'd',\n",
       " 'e',\n",
       " ' ',\n",
       " 't',\n",
       " 'o',\n",
       " ' ',\n",
       " 't',\n",
       " 'h',\n",
       " 'e',\n",
       " ' ',\n",
       " 'G',\n",
       " 'a',\n",
       " 'l',\n",
       " 'a',\n",
       " 'x',\n",
       " 'y']"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    ">>> book =\"The Hitchhiker's Guide to the Galaxy\"\n",
    ">>> booklist = list(book)\n",
    ">>> booklist"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "729c37d5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['T', 'h', 'e']"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    ">>> booklist[0:3]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "8bb0f82f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'The'"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    ">>> ''.join(booklist[0:3])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "81aef6b9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Galaxy'"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    ">>> ''.join(booklist[-6:])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c24a8529",
   "metadata": {},
   "source": [
    "### 从列表中每隔一个选择一个字母"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "26fbc067",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\"yxalaG eht ot ediuG s'rekihhctiH ehT\""
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    ">>> backwards = booklist[::-1]\n",
    ">>> ''.join(backwards)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "173ee769",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\"TeHthie' ud oteGlx\""
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    ">>> every_other = booklist[::2]\n",
    ">>> ''.join(every_other)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "0989eec8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Hitchhiker'"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    ">>> ''.join(booklist[4:14])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "e75113ea",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'rekihhctiH'"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    ">>> ''.join(booklist[13:3:-1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1b8722d0",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "60b4d7d4",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c232d550",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ee1f2c24",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9d2fd287",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0d678499",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "656288d0",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "60797139",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
